<%--
  Created by IntelliJ IDEA.
  User: dell、
  Date: 2017/5/10
  Time: 13:58
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%--<%@ taglib prefix="display" uri="http://displaytag.sf.net" %>--%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<html>
<head>

    <base href="<%=basePath%>">
    <meta charset="utf-8"/>
    <title>待催收任务</title>
    <%@ include file="../system/admin/top.jsp" %>
    <script src='static/js/jquery-2.1.3.min.js'></script>
    <script type="text/javascript" src="static/js/layer.js"></script>
    <link rel="stylesheet" href="static/css/layui.css" media="all">
    <script type="text/javascript" src="static/js/select2-4.0.3/js/select2.full.js"></script>
    <script type="text/javascript" src="static/js/jquery.json.min.js"></script>
    <link rel="stylesheet" href="static/js/select2-4.0.3/css/select2.min.css" media="all">
    <!-- 单选框 -->
    <script src="static/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="static/js/chosen.jquery.min.js"></script>
    <!-- 单选框 -->
    <!-- aJax表单提交 -->
    <script type="text/javascript" src="plugins/jquery.form.js"></script>
    <!-- aJax表单提交 -->
    <script type="text/javascript" src="js/sort.js"></script>
    <script type="text/javascript" src="static/js/bootstrap-datepicker.min.js"></script>
    <script src='static/js/commonJs.js${getTime}'></script>
    <script type="text/javascript" src="static/js/jquery.tips.js"></script>
    <style>
        #toGoPage {
            height: 30px;
        }

    </style>
    <link href="static/css/bootstrap.min.css" rel="stylesheet"/>

    <script type="text/javascript" src="static/js/bootstrap-datepicker.min.js"></script>
    <script>search("#pageForm");
    $(function () {
        $("input[placeholder],.ph").css({
            "font-size": "14px", "padding": "4px 6px", "color": "#000", "width": "100px"
        });
        $(top.hangge());
        //日期框
        $('.date-picker').datepicker();
        isFullChecked("allCk", "ck");

        //点击查询按钮
        $("#searchList").click(function () {
            //查询
            search("#pageForm");
        });

        //初始化select值
        initSelect();

        //excel导出
        exportExcel();

        doEmpty();

        //批量分派
        //分派
        $("#fenpai").click(function () {
            var index = layer.load();
            var mapList = new Array();
            var selector = "input[name='ck']";
            var ckLen = $(selector).size(), count = 0;
            $(selector).prop("checked", function (i, val) {
                if (val) {
                    mapList.push($(selector).eq(i).attr("data-id"));
                }
                else {
                    count++;
                }
            });
            if (ckLen == count) {
                layer.msg("请勾选要分派的数据！", {
                    icon: 5,
                    time: 2000
                });
                layer.close(index);
                return;
            } else {
                openDialog({
                    title: "批量分派操作",
                    url: "taskdetails/plliangfenpailist?fpId=" + mapList + "&flag=1",
                    callBack: function () {
                        window.location.reload();
                    }
                });
            }
            layer.close(index);
        });
        //平均分派
        $("#autoFenpai").click(function () {
            var mapList = new Array();
            var index = layer.load();
                openDialog({
                    title: "批量分派操作",
                    url: "taskdetails/plliangfenpailist?fpId=" + mapList +"&flag=auto"+"&total="+'${page.totalResult}',
                    callBack: function () {
                        window.location.reload();
                    }
                });
            layer.close(index);
        });

        $("#outPush").click(function () {
            var index = layer.load();
            var mapList = new Array();
            var selector = "input[name='ck']";
            var ckLen = $(selector).size(), count = 0;
            $(selector).prop("checked", function (i, val) {
                if (val) {
                    mapList.push($(selector).eq(i).attr("data-id"));
                }
                else {
                    count++;
                }
            });
            if (ckLen == count) {
                layer.msg("请勾选要委外的数据！", {
                    icon: 5,
                    time: 2000
                });
                layer.close(index);
                return;
            } else {
                //var r=confirm("是否确认批量委外?")
                layer.confirm('是否确认批量委外?', {
                    btn: ['确定', '取消'] //按钮
                }, function () {
                    $.ajax({
                        type: "post",
                        url: "loanTaskToBe/toWeiwai.do?ids=" + mapList,
                        success: function (data) {
                            var result = data
                            if (data == 'success') {
                                layer.alert("委外成功")
                                window.location.reload();
                            } else {
                                layer.alert("委外失败")
                            }
                        }
                    })
                });
            }
            layer.close(index);
        });

      /*  //统计逾期总金额ajax请求
        $("#pageForm").getSUM('count/money/status/0', getSelect2Val());*/
    });


 /*   function getSelect2Val() {
        //consoles($($("#pageForm").find("#overduePhase").get(0)).attr("value"));
        return $($("#pageForm").find("#overduePhase").get(0)).attr("value");
    }*/

    /***
     * 搜索
     * @param selector
     * @param url
     */
    function search(selector) {
//        $(selector).submit();
        $(selector).checkNumber();
    }

    /***
     * 初始化select值
     */
    function initSelect() {
        $.getJSON("<%=basePath%>loanTaskToBe/getSelectVal", function (json) {
            var select2Obj = $("#overduePhase").select2({
                data: json,
                language: "zh-CN",
            });
            //回显下拉框值
            select2Obj.val("${pd.overduePhase}").trigger("change");
            //统计逾期总金额ajax请求
            $("#pageForm").getSUM('count/money/status/0');
            return select2Obj;
        });

    }

    function myTrim(val) {
        return $.trim(val);
    }

    function exportExcel() {
        $(".exportExcelBtn").click(function () {
            if (myTrim($("[name='orderNum']").val())
                || myTrim($("[name='realName']").val())
                || myTrim($("[name='borrowNid']").val())
                || myTrim($("[name='idCard']").val())
                || myTrim($("[name='overdueDateNumMin']").val())
                || myTrim($("[name='overdueDateNumMax']").val())
                || myTrim($("[name='minOverdueAmount']").val())
                || myTrim($("[name='maxOverdueAmount']").val())
                || myTrim($("[name='productSource']").val())
                || myTrim($("[name='overduePhase']").val())
                || myTrim($("[name='minOverdueFee']").val())
                || myTrim($("[name='maxOverdueFee']").val())
                || myTrim($("[name='minCreateTime']").val())
                || myTrim($("[name='maxCreateTime']").val())
                || myTrim($("[name='telephone']").val())
            ) {
                window.location.href = '<%=basePath%>loanTaskToBe/excel.do?' + $("#pageForm").serialize();
				<%--$.getExcel('<%=basePath%>loanTaskToBe/excel2.do?' + $("#pageForm").serialize());--%>
            } else {
                var index = layer.load();
                layer.msg("请选择需要导出的数据！", {
                    icon: 5,
                    time: 2000
                });
                layer.close(index);
                //layer.alert("请选择需要导出的数据");
            }
        });
    }

    function doEmpty() {
        $("#doEmpty").click(function () {
            //initSelect();
            $("[name='overduePhase']").select2('val', '1')
            $("[name='orderNum']").val("")
            $("[name='realName']").val("")
            $("[name='borrowNid']").val("")
            $("[name='callLoanNid']").val("")
            $("[name='idCard']").val("")
            $("[name='overdueDateNumMin']").val("")
            $("[name='overdueDateNumMax']").val("")
            $("[name='minOverdueAmount']").val("")
            $("[name='maxOverdueAmount']").val("")
            $("[name='productSource']").val("")
            $("[name='minOverdueFee']").val("")
            $("[name='maxOverdueFee']").val("")
            $("[name='minCreateTime']").val("")
            $("[name='maxCreateTime']").val("")
            $("[name='telephone']").val("")
        });
    }

    /* 打开窗口 */
    function openDialog(options) {
        var defaultOptions = {
            title: "",
            url: "",
            callBack: function () {
            }
        };
        options = $.extend(defaultOptions, options);
        layer.open({
            title: options.title,
            fixed: false,
            type: 2,
            content: options.url,
            area: ['800px', '600px'],
            end: options.callBack
        });
    }

    //菜单状态切换
    var fmid = "fhindex";
    var mid = "fhindex";

    function siMenu(id, fid, MENU_NAME, MENU_URL) {
        if (id != mid) {
            $("#" + mid).removeClass();
            mid = id;
        }
        if (fid != fmid) {
            $("#" + fmid).removeClass();
            fmid = fid;
        }
        $("#" + fid).attr("class", "active open");
        $("#" + id).attr("class", "active");
        // top.mainFrame.tabAddHandler(id,MENU_NAME,MENU_URL);
        top.mainFrame.tab.update({
            id: mid,
            title: MENU_NAME,
            url: MENU_URL,
            isClosed: true
        });
        top.mainFrame.tab.add({
            id: mid,
            title: MENU_NAME,
            url: MENU_URL,
            isClosed: true
        });
        top.mainFrame.tab.activate(mid);

        top.mainFrame.taba
        if (MENU_URL != "druid/index.html") {
            jzts();
        }
    }

    //显示加载进度
    function jzts() {
        $("#jzts").show();
    }
    </script>
    <!-- 表头排序插件 -->
    <script type="text/javascript" charset="utf-8">
        /* $(function(){
            $('#table_report').dataTable({
                 "aoColumnDefs": [{ "bSortable": false, "aTargets": [0,1,2,3,4,5,6,8,10]}],
                 "aaSorting": [[1,2,3,4,5,6,7,9,11, "desc"]],
                 "bLengthChange":false, //关闭每页显示多少条数据
                 "bPaginate": false, //翻页功能
                 "bFilter":false, //过滤功能
                 "bPaginate":false,//是否使用分页

            });
            $("#table_report_info").hide();
        }) */
    </script>
    <style>
        .divcss5 {
            width: 150px;
            height: 30px;
        }

         
    </style>
</head>
<body>
<div class="container-fluid" id="main-container" style="width: 1900px">
    <div id="page-content" class="clearfix">
        <div class="row-fluid">
            <div class="row-fluid" id="my1213">
                <!-- 检索  -->
                <form action="<%=basePath%>loanTaskToBe/list" method="post" name="pageForm" id="pageForm"
                      class="form-inline">
                    <div style="border: 1px solid darkgray;padding: 6px; ">
                        <table>
                            <tr>
                                <td>
                                    <div class="pull-left search "
                                         style="text-align: center;margin-left: 20px;margin-top:20px">
                                        借款产品:
                                        <select id="productSource" name="productSource" value="${pd.productSource}"
                                                style="width: 100px;height: 30px;">
                                            <option value="">不限</option>
                                            <option value="2"
                                                    <c:if test="${'2' eq pd.productSource}">selected</c:if>>今日现金
                                            </option>
                                            <option value="6"
                                                    <c:if test="${'6' eq pd.productSource}">selected</c:if>>卡贷
                                            </option>
                                            <option value="39"
                                        			<c:if test="${'39' eq pd.productSource}">selected</c:if>>融360
                                			</option>
                                			<option value="41"
						                             <c:if test="${'41' eq pd.productSource}">selected</c:if>>消费分期
									        </option>
									        <option value="43"
									                 <c:if test="${'43' eq pd.productSource}">selected</c:if>>游戏贷
									        </option>
									        <option value="8"
						            				<c:if test="${'8' eq pd.productSource}">selected</c:if>>教育分期
						    				</option>
                                        </select>
                                    </div>
                                </td>
                                <td>
                                    <div class="pull-left search "
                                         style="text-align: center;margin-left: 20px;margin-top:20px">
                                        入案时间:
                                        <input type="text" class="form-control date-picker divcss5"
                                               data-date-format="yyyy-mm-dd"
                                               name="minCreateTime" value="${pd.minCreateTime}"
                                               style="height: 30px; width: 100px"/>
                                        至 <input type="text" class="form-control date-picker divcss5"
                                                 data-date-format="yyyy-mm-dd"
                                                 name="maxCreateTime" value="${pd.maxCreateTime}"
                                                 style="height: 30px; width: 100px"/>
                                    </div>
                                </td>
                                <td>
                                    <div class="pull-left search "
                                         style="text-align: center;margin-left: 20px;margin-top:20px">
                                        逾期天数:
                                        <input type="text" class="form-control divcss5" name="overdueDateNumMin"
                                               value="${pd.overdueDateNumMin}" style="font-size: 14px;padding: 4px 6px;color: #000;width: 100px;height: 30px;"
                                               checkNumber/>至
                                        <input type="text" class="form-control divcss5" name="overdueDateNumMax"
                                               value="${pd.overdueDateNumMax}" style="font-size: 14px;padding: 4px 6px;color: #000;width: 100px;height: 30px;"
                                               checkNumber/>
                                    </div>
                                </td>
                                <td>
                                    <div class="pull-left search "
                                         style="text-align: center;margin-left: 20px;margin-top:20px">
                                        待还金额:
                                        <input type="text" class="form-control divcss5" name="minOverdueAmount"
                                               value="${pd.minOverdueAmount}" style="font-size: 14px;padding: 4px 6px;color: #000;width: 100px;height: 30px;"/>
                                        至 <input type="text" class="form-control divcss5" name="maxOverdueAmount"
                                                 value="${pd.maxOverdueAmount}"  style="font-size: 14px;padding: 4px 6px;color: #000;width: 100px;height: 30px;"/>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <div class="pull-left search "
                                         style="text-align: center;margin-left: 20px;margin-top:10px">
                                        逾期阶段:
                                        <select id="overduePhase" name="overduePhase" value="${pd.overduePhase}"
                                                style="width: 100px"></select>
                                    </div>
                                </td>
                                <td>
                                    <div class="pull-left search "
                                         style="text-align: center;margin-left: 20px;margin-top:10px">
                                        未还罚息:
                                        <input type="text" class="form-control divcss5 ph" name="minOverdueFee"
                                               value="${pd.minOverdueFee}"
                                               style="font-size: 14px;padding: 4px 6px;color: #000;width: 100px;height: 30px;"/>
                                        至 <input type="text" class="form-control divcss5 ph" name="maxOverdueFee"
                                                 value="${pd.maxOverdueFee}"
                                                 style="font-size: 14px;padding: 4px 6px;color: #000;width: 100px;height: 30px;"/>
                                    </div>
                                </td>
                            </tr>
                        </table>
                        <div class="pull-left" style="margin-left: 20px;margin-top:10px">自定义项:
                            <input type="text" class="form-control divcss5" name="telephone" id="telephone1"
                                   placeholder="手机号（本人）"
                                   value="${pd.telephone}"
                                   style="width: 100px;height: 30px;height: 30px"/>
                        </div>
                        <div class="pull-left search" style="margin-left: 10px;margin-top:10px">
                            <input type="text" class="form-control divcss5" name="idCard" value="${pd.idCard}"
                                   placeholder="借款人身份证"
                                   style="width: 100px;height: 30px;height: 30px"/>
                        </div>

                        <div class="pull-left search" style="margin-left: 10px;margin-top:10px">
                            <input type="text" class="form-control divcss5" name="realName" value="${pd.realName}"
                                   placeholder="借款人姓名"
                                   style="width: 100px;height: 30px;height: 30px"/>
                        </div>
                        <div class="pull-left search" style="margin-left: 10px;margin-top:10px">
                            <input   type="text" class="form-control divcss5 "
                                   placeholder="借款编号"
                                   name="borrowNid" value="${pd.borrowNid }"
                                   style="width: 100px;height: 30px;height: 30px"/>
                        </div>
                        <div class="pull-left search" style="margin-left: 10px;margin-top:10px;">
                            <input   type="text" class="form-control divcss5 "
                                   placeholder="催收编号"
                                   name="callLoanNid" value="${pd.callLoanNid }"
                                   style="width: 100px;height: 30px;height: 30px"/>
                        </div>
                        <div class="pull-left search" style="margin-left: 10px;margin-top:10px">
                            <input type="text" class="divcss5" name="orderNum" value="${pd.orderNum}"
                                   placeholder="还款订单号"
                                   style="width: 100px;height: 30px;height: 30px"/>
                        </div>
                        <div class="form-line" style="line-height: 40px">
                            <input type="hidden" class="form-control divcss5" id="" value="${startNum}"
                                   style="height: 30px"/>
                            <input type="hidden" class="form-control divcss5" value="${endNum}" style="height: 30px"/>
                            <!-- 排序 -->
                            <input type="hidden" id="sortFindByAmount1" name="sortFindByAmount"
                                   value="${pd.sortFindByAmount}">
                            <input type="hidden" id="sortFindByDay1" name="sortFindByDay" value="${pd.sortFindByDay}">
                            <!-- 排序 -->
                            <br>
                            <div style="width:100%;margin-top: 25px">
                                <label class="btn btn-primary btn-lg" id="searchList">查询</label>
                                <label class="btn btn-primary btn-lg" id="doEmpty">清空</label>
                                <c:if test="${QX3==1}">
                                    <label class="btn btn-primary btn-lg" id="fenpai">批量分派</label></c:if>
                                <c:if test="${QX1==1}">
                                    <label class="btn btn-primary btn-lg exportExcelBtn">导出Excel</label></c:if>
                                <c:if test="${QX4==1}">
                                    <label class="btn btn-primary btn-lg" id="outPush">批量委外</label></c:if>
                                <c:if test="${QX3==1}">
                                    <label class="btn btn-primary btn-lg" id="autoFenpai">平均分派</label></c:if>
                            </div>
                        </div>
                    </div>
                    <table id="table_report"
                           class="table table-striped table-bordered table-hover"
                           style="margin-top: -20px; font-size: 13px"
                    >
                    <thead>
                    <tr>
                        <th><input type="checkbox" name="allCk"
                                   style='margin-left: 5px;position:relative;opacity:100;' title="全选"></th>
                        <th>催收编号</th>
                        <th>借款人姓名</th>
                        <!-- <th>手机号</th>
                        <th>借款人身份证</th>
                        <th>借款编号</th> -->
                        <th>借款产品名称</th>
                        <th>逾期期数</th>
                        <th>
                            <button id="overAmountOrd" onclick="sortchaxunbyamount('${sortFindByamount}');">待还金额
                            </button>
                        </th>
                        <th>逾期阶段</th>
                        <th>
                            <button id="overAmountOrd1" onclick="sortchaxunbyday('${sortFindByday}');">逾期天数</button>
                        </th>
                        <th>入案时间</th>
                        <th>还款订单号</th>
                        <!-- <th>操作</th> -->
                    </tr>
                    </thead>
                    <tbody>
                    <!-- 开始循环 -->
                    <c:choose>
                        <c:when test="${not empty resultList}">
                            <c:forEach items="${resultList}" var="var" varStatus="vs">

                                <tr>
                                    <td class='center' style="width: 30px;">
                                        <input type="checkbox" data-id="${var.call_loan_nid}" name="ck"
                                               style='position:relative;opacity:100;'
                                               data-entity='{"call_loan_nid":"${var.call_loan_nid}",
                                                		"repayment_id":"${var.repayment_id}",
                                                        "real_name":"${var.real_name}",
                                                        "telephone":"${var.telephone}",
                                                       "cont_id_card":"${var.cont_id_card }",
                                                       "borrow_nid":"${var.borrow_nid }",
                                                       "product_name":"${var.product_name}",
                                                       "periods":"${var.period}/${var.period_total}",
                                                       "overdue_amount":"${var.overdue_amount}",
                                                       "overdue_stage":"${var.overdue_stage}",
                                                       "overdue_date":"${var.overdue_date}"}'>
                                    </td>
                                    <td>
                                       <%-- <a href="cuijimanage/toDescPage.do?callLoanNid=${var.call_loan_nid}
                                                &userId=${var.user_id}&repaymentId=${var.repayment_id}"
                                           style="color: blue;">${var.call_loan_nid}</a>--%>
                                        <a href="javascript:void(0)" onclick="$.tiaozhuan(this,'${var.call_loan_nid}','${var.user_id}','${var.repayment_id}','${var.real_name}','dai')"
                                           style="color: blue">
                                                ${var.call_loan_nid}
                                        </a>
                                    </td>
                                    <td>${var.real_name}</td>
                                    <%-- <td>${var.telephone}</td>
                                    <td>${var.cont_id_card }</td>
                                    <td>${var.borrow_nid }</td> --%>
                                    <td>${var.product_name}</td>
                                    <td>${var.period}/${var.period_total}</td>
                                    <td>${var.overdue_amount}</td>
                                    <td>${var.overdue_stage}</td>
                                    <td>${var.overdue_date}</td>
                                    <td>
                                        <fmt:formatDate value="${var.create_time}" pattern="yyyy-MM-dd HH:mm:ss"/>
                                    </td>
                                    <td>${var.repayment_id}</td>
                                        <%--<td>
                                                <a  href="cuijimanage/toDescPage.do?callLoanNid=${var.call_loan_nid}
                                            &userId=${var.user_id}&borrowNid=${var.borrow_nid}"
                                                    style="color: blue;">查看详情</a>
                                        </td>--%>
                                </tr>
                            </c:forEach>
                        </c:when>
                        <c:otherwise>
                            <tr class="main_info">
                                <td colspan="100" class="center">没有相关数据</td>
                            </tr>
                        </c:otherwise>
                    </c:choose>
                    </tbody>
                    </table>
                    <div class="page-header position-relative">
                        <span id="getSUM"></span>
                        <table style="width: 100%;">
                            <tr>
                                <td style="vertical-align: top;">
                                    <div class="pagination"
                                         style="float: right; padding-top: 0px; margin-top: 0px;">${page.pageStr}</div>
                                </td>
                            </tr>
                        </table>
                    </div>
                </form>
            </div>
            <!-- PAGE CONTENT ENDS HERE -->
        </div>
        <!--/row-->
    </div>
    <!--/#page-content-->
</div>
<!--/.fluid-container#main-container-->
<!-- 返回顶部  -->
<a href="#" id="btn-scroll-up" class="btn btn-small btn-inverse"> <i
        class="icon-double-angle-up icon-only"></i>
</a>
<!-- 引入 -->
<%--<script type="text/javascript">
    window.jQuery
    || document
        .write("<script src='static/js/jquery-3.2.1.min.js'><\/script>");
</script>--%>

</body>
</html>
